include_defs('//ReactAndroid/DEFS')

# We depend on JSC, support the same platforms
SUPPORTED_PLATFORMS = '^android-(armv7|x86)$'

DEPS = [
  '//native/fb:fb',
  '//native/jni:jni',
  '//native/third-party/android-ndk:android',
  '//xplat/fbsystrace:fbsystrace',
  '//xplat/folly:molly',
]

PREPROCESSOR_FLAGS = [
  '-DLOG_TAG="ReactNative"',
  '-DWITH_JSC_EXTRA_TRACING=1',
  '-DWITH_FBSYSTRACE=1',
]

def react_library(**kwargs):
  cxx_library(
    name = 'react',
    visibility = [
      react_native_target('jni/react/jni:jni'),
    ],
    deps = DEPS + [
      '//native/third-party/jsc:jsc',
      '//native/third-party/jsc:jsc_legacy_profiler',
    ],
    preprocessor_flags = PREPROCESSOR_FLAGS,
    **kwargs
  )

react_library(
  soname = 'libreactnative.so',
  header_namespace = 'react',
  supported_platforms_regex = SUPPORTED_PLATFORMS,
  force_static = True,
  srcs = [
    'Bridge.cpp',
    'JSModulesUnbundle.cpp',
    'Value.cpp',
    'MethodCall.cpp',
    'JSCHelpers.cpp',
    'JSCExecutor.cpp',
    'JSCTracing.cpp',
    'JSCMemory.cpp',
    'JSCPerfLogging.cpp',
    'JSCLegacyProfiler.cpp',
    'JSCWebWorker.cpp',
  ],
  headers = [
    'JSCTracing.h',
    'JSCPerfLogging.h',
    'JSCLegacyProfiler.h',
    'JSCMemory.h'
  ],
  exported_headers = [
    'Bridge.h',
    'Executor.h',
    'JSCExecutor.h',
    'JSCHelpers.h',
    'JSCWebWorker.h',
    'MethodCall.h',
    'JSModulesUnbundle.h',
    'Value.h',
  ],
  compiler_flags = [
    '-Wall',
    '-std=c++11',
    '-fexceptions',
    '-fvisibility=hidden',
  ],
)
